﻿using System;
using System.Net;
using System.Net.Http;
using System.Net.Security;
using System.Threading.Tasks;

namespace Microsoft.Cloud.API.AzurePack.Services
{
    /// <summary>
    /// 
    /// </summary>
    public abstract class WAPBaseService : IDisposable
    {
        public WAPBaseService()
        {
            ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(delegate { return true; });
        }

        public HttpClient TheHttpClient
        {
            get;
            set;
        }

        public async Task<HttpResponseMessage> GetAsync(string url)
        {
            var response = await TheHttpClient.GetAsync(url);

            return response;
        }

        public async Task<HttpResponseMessage> PostAsync(string url)
        {
            var response = await TheHttpClient.PostAsync(url, null);

            return response;
        }

        public void Dispose()
        {
            if (this.TheHttpClient != null)
            {
                this.TheHttpClient.Dispose();
            }
        }
    }
}